# CMakeLists.txt
cmake_minimum_required(VERSION 3.28)
project(pain)

set(CMAKE_CXX_STANDARD 17)
find_package(Threads REQUIRED)
include_directories(${CMAKE_SOURCE_DIR}/src)
#target_include_directories(pain PRIVATE src)
# 收集所有源文件
#file(GLOB_RECURSE ALL_SOURCES "src/*.cpp")
file(GLOB_RECURSE ALL_SOURCES
        CONFIGURE_DEPENDS
        "${CMAKE_SOURCE_DIR}/src/*.cpp")
#set(CMAKE_CXX_COMPILER "clang++")

# sql解析
# 手动把 Hyrise 源码编成静态库
file(GLOB_RECURSE HSQL_SRC CONFIGURE_DEPENDS
        ${CMAKE_SOURCE_DIR}/src/external/sql-parser/src/*.cpp
)
# 可选：打印数量，防止摸空
list(LENGTH HSQL_SRC HSQL_SRC_LEN)
message(STATUS "hsql .cpp count = ${HSQL_SRC_LEN}")
add_library(sqlparser STATIC ${HSQL_SRC})
target_include_directories(sqlparser PUBLIC ${CMAKE_SOURCE_DIR}/src/external/sql-parser/src)

# 创建单个可执行文件
add_executable(pain ${ALL_SOURCES})
#target_link_libraries(pain PRIVATE Threads::Threads)
target_link_libraries(pain Threads::Threads sqlparser)



target_precompile_headers(pain PRIVATE src/pch.hpp)
if(WIN32)
    target_link_libraries(pain ws2_32)
endif()

set_target_properties(pain PROPERTIES
        RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)